<html>
 <head>
    <title>[var.TITLE]</title>
    <link href="[var.ROOT_CSS_DIR]/main.css" rel="STYLESHEET" type="text/css" charset="iso-8859-1" hreflang="en-us">
    <link href="[var.ROOT_CSS_DIR]/facet/style.css" rel="STYLESHEET" type="text/css" charset="iso-8859-1" hreflang="en-us">
    <script type="text/javascript" src="[var.ROOT_DIR]js/common.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/doiMenuDOM.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/functions.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsmenu.php"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsmenu.cfg"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsmasks.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jquery.min.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsformgridnew.js"></script>
 </head>
 <body bgcolor="FFFFFF" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
    <table border="0" cellspacing="0" cellpadding="0" width="100%" align="[var.POSITION]">
        <tr height="100%">
            <td>
            <table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
                <tr valign="top">
                    <td width="100%">
                        <table border="0" cellspacing="0" cellpadding="5" width="100%">
                            <tr>
                                <td class="FacetHeaderContent" align="left">.:Activity Lookup:. </td>
                            </tr>
                        </table>
                        <table border="0" cellspacing="0" cellpadding="5" width="100%">
                            <tr>
                                <td class="content2">
                                    <table border="0" cellspacing="0" cellpadding="0">
                                    <form  method="post" action="[var.FileName]?FormName=[var.FormName]&[var.PreserveGet]">
                                        <tr>
                                            <td class="fieldCaption">Activity Code</td>
                                            <td class="fieldCaption">:</td>
                                            <td>
                                            <input type="text" name="codeSearch" size="10" maxlength="50" class="input" value="[var.FCode]">
                                                                                                                                                                                                    <input type="hidden" name="SendToBack" value="1">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="fieldCaption">Activity Name</td>
                                            <td class="fieldCaption">:</td>
                                            <td>
                                            <input type="text" name="nameSearch" size="35" maxlength="50" class="input" value="[var.FNama]">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="menuHeader"></td>
                                            <td class="menuHeader"></td>
                                            <td align="right">
                                            <!--input type="button" value="Add New" class="button" onclick="AddNew();"-->
                                            <input type="submit" name="Action" value="Search" class="button" >
                                            </td>
                                        </tr>
                                    </form>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                            </tr>
                            <tr>
                                <td >&nbsp;</td>
                            </tr>
                        </table>
                        <table border="0" cellspacing="0" cellpadding="0" width="100%">
                            <tr>
                              <td>
                         <!-- GRID SECTION -->
                                    <table border="0" width="100%" cellpadding="3" cellspacing="1" class="FacetFormTABLE" align="left">
                                    <form method=post name="[var.HTMLGridList]" >
                                      <tr>
                                        <td nowrap class="FacetColumnTD" align="center">No.</td>
                                        <td nowrap class="FacetColumnTD" align="center">Service Code</td>
                                        <td nowrap class="FacetColumnTD" align="center">Service Name</td>
                                        <td nowrap class="FacetColumnTD" align="center">Service Quantity</td>
                                        <td nowrap class="FacetColumnTD" align="center">Activity Code</td>
                                        <td nowrap class="FacetColumnTD" align="center">Activity Name</td>
                                        <td nowrap class="FacetColumnTD" align="center">Activity Quantity</td>
                                        <td nowrap class="FacetColumnTD" align="center">Currency</td>
                                        <td nowrap class="FacetColumnTD" align="center">Total Amount</td>
                                        <td nowrap class="FacetColumnTD" align="center">AP Status</td>
                                      </tr>

                                      <tr>
                                        <td nowrap class="FacetDataTD">[blg.#]</td>
                                        <td class="FacetDataTD">
                                           <a href="javascript:if(checkData('[blg.activities_id]', '[blg.ap_status]') == 1) {GetCustomer('[blg.jo_costing_id]', '[blg.services_id]', '[blg.activities_id]', '[blg.services_name]', '[blg.qty_service]', '[blg.actname]', '[blg.qty_activity]','[blg.unit]', '[blg.curr]', '[blg.rate]', '[blg.amount]', '[blg.base_amount]', '[blg.tax_rate]', '[blg.tax_amount]', '[blg.total_amount]', '[blg.budget_remain]', '[blg.qty_activity_remain]', '[blg.tax_amount_usd]', '[blg.total_amount_usd]', '[blg.skada]', '[blg.CUDEBTUR_FIN]', '[blg.CUNAME]', '[blg.budget_ap_remain]');}">[blg.services_code]</a>
                                        </td>
                                        <td class="FacetDataTD">[blg.services_name;block=tr;]</td>
                                        <td class="FacetDataTD">[blg.qty_service]</td>
                                        <td class="FacetDataTD">[blg.actcode]</td>
                                        <!--td class="FacetDataTD"><a href="javascript:checkData('[blg.actname]');">[blg.actname]</a></td-->
                                        <td class="FacetDataTD">[blg.actname]</td>
                                        <td class="FacetDataTD">[blg.qty_activity]</td>
                                        <td class="FacetDataTD">[blg.curr]</td>
                                        <td class="FacetDataTD">[blg.total_amount;frm='0,000.00']</td>
                                        <td class="FacetDataTD">[blg.ap_status]</td>
                                      </tr>

                                      <tr>
                                        <td colspan="10" class="FacetDataTD">[blg;block=tr;nodata]No records</td>
                                      </tr>

                                      <tr>
                                        <td colspan="10" nowrap class="FacetColumnTD">[tbs_check.1;block=tr;if [var.RecCnt]!=0]
                                            <table border="0" align="left" cellpadding="0" cellspacing="0">
                                              <tr align="center">[tbs_check.1;block=table;if [var.RecCnt]!=0]
                                                <td width="16" class="FacetColumnTD"><a href="[sys.script_name]?PageNum=[nv.first;endpoint;friend2=a]&[var.PreserveGet]">|&lt;</a></td>
                                                <td width="16" class="FacetColumnTD"><a href="[sys.script_name]?PageNum=[nv.prev;endpoint;friend2=a]&[var.PreserveGet]">&lt;</a></td>
                                                <td width="16" class="FacetColumnTD"><a href="[sys.script_name]?PageNum=[nv.page;block=td]&[var.PreserveGet]">[nv.page]</a></td>
                                                <td width="16" bgcolor="#B7B3B7"><strong>[nv.page;block=td;currpage]</strong></td>
                                                <td width="16" class="FacetColumnTD"><a href="[sys.script_name]?PageNum=[nv.next;endpoint;friend2=a]&[var.PreserveGet]">&gt;</a></td>
                                                <td width="16" class="FacetColumnTD"><a href="[sys.script_name]?PageNum=[nv.last;endpoint;friend2=a]&[var.PreserveGet]">&gt;|</a></td>
                                              </tr>
                                            </table>
                                        </td>
                                      </tr>
                                      </form>
                                    </table>
                        <!-- GRID SECTION -->
                               </td>
                            </tr>
                            <tr>
                              <td>

                              &nbsp;
                              </td>
                            </tr>
                            </table>
                    </td>
                </tr>
            </table>

            </td>
        </tr>
    </table>
 </body>
<script>


 var Address;
 var NPWP;

 function SetOther(addr,npwp) {
    Address = addr;
    NPWP = npwp;
 }

 function GetCustomer(jo_costing_id, services_id, activities_id, services_name, qty_service, actname, qty_activity, unit, curr, rate, amount, base_amount, tax_rate, tax_amount, total_amount, budget_remain, qty_activity_remain, tax_amount_usd, total_amount_usd, skada, debtur, debnam, budget_ap_remain) {

 oMask = new Mask('#,###.#0', 'number');

 var BufferOpener;
 var no_urut = [var.no_urut];
 var total = 0;



    for(i=1;i<=10;i++){
        eval("var TotalAmount = window.opener.document.[var.FormName].jumlah"+i+".value");

        if(TotalAmount == "") {
            TotalAmount = 0;
        }

        TotalAmount = String(TotalAmount);
        TotalAmount = (TotalAmount.replace(/,/g, "")) * 1;

            //alert("TotalAmount: " + TotalAmount);
        total = total + TotalAmount;
        //alert("total: " + total);
    }

    //alert(budget_ap_remain);





    budget_ap_remain = String(budget_ap_remain);
    budget_ap_remain = (budget_ap_remain.replace(/,/g, "")) * 1;

    total = total + budget_ap_remain;
    //alert("total: " + total);
    var maskTotalAmount = oMask.format(total);

    window.opener.document.[var.FormName].total_trans.value = maskTotalAmount;


     BufferOpener = window.opener.document.body.innerHTML;

     var maskRate = oMask.format(rate);
     var maskAmount = oMask.format(amount);
     var maskBaseAmount = oMask.format(base_amount);
     var maskTaxRate = oMask.format(tax_rate);
     var maskTaxAmount = oMask.format(tax_amount);
     var maskTaxAmountUsd = oMask.format(tax_amount_usd);
     var maskTotalAmount = oMask.format(total_amount);
     var maskBudgetRemain = oMask.format(budget_remain);
     var maskBudgetApRemain = oMask.format(budget_ap_remain);




     if(no_urut != "")
     {
        
        window.opener.document.[var.FormName].services_id[var.no_urut].value = services_id;
        window.opener.document.[var.FormName].activities_id[var.no_urut].value = activities_id;
        window.opener.document.[var.FormName].uraian[var.no_urut].value = actname ;
        window.opener.document.[var.FormName].jumlah[var.no_urut].value = maskBudgetApRemain ;
        window.opener.document.[var.FormName].max_amount[var.no_urut].value = maskBudgetApRemain ;
        window.opener.document.[var.FormName].skada[var.no_urut].value = skada ;
        window.opener.document.[var.FormName].debtur[var.no_urut].value = debtur ;
        window.opener.document.[var.FormName].debnam[var.no_urut].value = debnam ;
        window.opener.document.[var.FormName].jo_costing_id[var.no_urut].value = jo_costing_id ;

     }

     else
     {
        window.opener.document.[var.FormName].services_id.value = services_id;
        window.opener.document.[var.FormName].activities_id.value = activities_id;
        window.opener.document.[var.FormName].uraian.value = actname ;
        //window.opener.document.[var.FormName].jumlah.value = total_amount ;
        window.opener.document.[var.FormName].jumlah[var.no_urut].value = maskBudgetApRemain ;
        window.opener.document.[var.FormName].max_amount[var.no_urut].value = maskBudgetApRemain ;
        window.opener.document.[var.FormName].skada.value = skada ;
        window.opener.document.[var.FormName].debtur.value = debtur ;
        window.opener.document.[var.FormName].debnam.value = debnam ;
        window.opener.document.[var.FormName].jo_costing_id[var.no_urut].value = jo_costing_id ;
     }



     self.close();
 }



 function AddNew() {
    self.location.replace('ais_transaction_debtur.php?PageMode=Form');
 }



 function checkData(val, status){
    var result = 1;

    for(i=1;i<=10;i++){
        if( val == eval("window.opener.document.[var.FormName].activities_id"+i+".value")){
            alert("Data yang anda pilih sudah termasuk di dalam list Account Payable");
            result = 0;
            break;
        }

    }

    if(status =="Y"){
        alert("Data yang anda pilih sudah di BS");
        result = 0;
    }



    return result;

 }
</script>
</html>
